var szu = new Array();
img = $(this).children().eq(0).html();
txt = $(".right_text");
info = $(".right_xianshi");
$time = $(this).children().eq(1).eq(0).children().eq(1);
$liao = $(this).children().eq(2);

$("#right_main_1").click(function(event) {
	var $this = event.target ? event.target : event.srcElement;
	if($this.type == "button") {
		cli();
	}
});
var xianshi = "";

function cli() {
	var num = parseInt(Math.random() * 4) + 1;
	xianshi += txt.html();
	//右
	info.append("<div class='time'>" + getTime() + "</div>"); //时间
	info.append("<div class='rright'><img src='../img/427e28f58d3a5a9ce270dde491cf5bee.jpg' /> </div>") //头像
	info.append("<div class='rleft'><div class='arrow2'></div><div class='neirong'>" + xianshi + "</div></div>")
	info.append("<div class='cle'></div>");
	//左
	$.post("http://www.tuling123.com/openapi/api", {
		key: "26c463640125432b9f275ffe6d999c05",
		info: xianshi,
		userid: "12345678"
	}, function(data) {
		//机器人返回的信息
		info.append("<div class='time'>" + getTime() + "</div>"); //时间
		info.append("<div class='lleft'><img src='../img/e1f21ae82f41949a962c764e62300780.jpg'/></div>"); //头像
		if(data.url) {
			info.append("<div class='lright'><div class='arrow1'></div><div class='neirong'>" + data.text + "<a target='_blank' href='" + data.url + "'>打开页面</a>" + "</div></div>");
		} else if(data.list) {
			info.append('<div class="lright">' + '<div class="xinwen"><div class="xinwen_1"><a target="_blank" href="' + data.list[0].detailurl + '"><p>' + data.list[0].article + '</p></a><a target="_blank" href="' + data.list[0].detailurl + '"><img src="' + data.list[0].icon + '" /></a></div><div class="xinwen_2"><a target="_blank" href="' + data.list[1].detailurl + '"><div class="mark">' + data.list[1].article + '</div></a><a target="_blank" href="' + data.list[1].detailurl + '"><img src="' + data.list[1].icon + '" /></a></div><div class="xinwen_2"><a target="_blank" href="' + data.list[2].detailurl + '"><div class="mark">' + data.list[2].article + '</div></a><a target="_blank" href="' + data.list[2].detailurl + '"><img src="' + data.list[2].icon + '" /></a></div><div class="xinwen_2"><a target="_blank" href="' + data.list[3].detailurl + '"><div class="mark">' + data.list[3].article + '</div></a><a target="_blank" href="' + data.list[3].detailurl + '"><img src="' + data.list[3].icon + '" /></a></div></div>' + '</div>');
		} else {
			info.append("<div class='lright'><div class='arrow1'></div><div class='neirong'>" + data.text + "</div></div>");
		}
		info.append("<div class='cle'></div>");
		info[0].scrollTop = info[0].scrollHeight;
	});

	txt.html("");
	xianshi = "";
	info[0].scrollTop = info[0].scrollHeight;
}

function dd(num) {
	return num < 10 ? "0" + num : num;
}

function getTime() {
	var time = new Date();
	var hh = dd(time.getHours());
	var mm = dd(time.getMinutes());
	return hh + ":" + mm;
}

function backhome(event) {
	if(event.ctrlKey && !event.keyCode == 13) {
		txt.html(txt.html() + '\n');
	}
}
window.onkeydown = function(event) {
	if(event.keyCode == 13 && event.ctrlKey) {
		cli();
	}
}